<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.10.0" />
<title>py3dtilers.Common.feature API documentation</title>
<meta name="description" content="" />
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>py3dtilers.Common.feature</code></h1>
</header>
<section id="section-intro">
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">import numpy as np
from py3dtiles import BoundingVolumeBox, TriangleSoup

from ..Color import ColorConfig


class Feature(object):
    &#34;&#34;&#34;
    The base class of all object that need to be tiled, in order to be
    used with the corresponding tiler.
    &#34;&#34;&#34;

    def __init__(self, id=None):
        &#34;&#34;&#34;
        :param id: given identifier
        &#34;&#34;&#34;

        self.geom = TriangleSoup()

        # Optional application specific data to be added to the batch table for this object
        self.batchtable_data = None

        # A Bounding Volume Box object
        self.box = None

        # The centroid of the box
        self.centroid = np.array([0, 0, 0])

        self.texture = None

        self.material_index = 0

        self.set_id(id)

    def set_id(self, id):
        &#34;&#34;&#34;
        Set the id of this feature.
        :param id: an id
        &#34;&#34;&#34;
        self.id = id

    def get_id(self):
        &#34;&#34;&#34;
        Return the id of the feature.
        &#34;&#34;&#34;
        return self.id

    def set_batchtable_data(self, data):
        &#34;&#34;&#34;
        Set the batch table data associed to this feature.
        :param data: a dictionary
        &#34;&#34;&#34;
        self.batchtable_data = data

    def get_batchtable_data(self):
        &#34;&#34;&#34;
        Return the batch table data associed to this feature.
        :return: a dictionary
        &#34;&#34;&#34;
        return self.batchtable_data

    def get_centroid(self):
        &#34;&#34;&#34;
        Return the centroid of this feature.
        :return: a 3D point as np array
        &#34;&#34;&#34;
        return self.centroid

    def get_bounding_volume_box(self):
        &#34;&#34;&#34;
        Return the BoundingVolumeBox of this feature.
        :return: a BoundingVolumeBox
        &#34;&#34;&#34;
        return self.box

    def get_geom_as_triangles(self):
        &#34;&#34;&#34;
        Return the triangles of this feature.
        :return: a list of triangles
        &#34;&#34;&#34;
        return self.geom.triangles[0]

    def set_triangles(self, triangles):
        &#34;&#34;&#34;
        Set the triangles of this feature.
        :param triangles: a list of triangles.
        &#34;&#34;&#34;
        self.geom.triangles[0] = triangles

    def set_box(self):
        &#34;&#34;&#34;
        Set the BoundingVolumeBox of this feature from its triangles.
        Also set the centroid.
        &#34;&#34;&#34;
        bbox = self.geom.getBbox()
        self.box = BoundingVolumeBox()
        self.box.set_from_mins_maxs(np.append(bbox[0], bbox[1]))

        # Set centroid from Bbox center
        self.centroid = np.array(self.box.get_center())

    def get_texture(self):
        &#34;&#34;&#34;
        Return the texture image of this feature.
        :return: a Pillow image
        &#34;&#34;&#34;
        return self.texture

    def set_texture(self, texture):
        &#34;&#34;&#34;
        Set the texture image of this feature.
        :param texture: a Pillow image
        &#34;&#34;&#34;
        self.texture = texture

    def has_texture(self):
        &#34;&#34;&#34;
        Check if the feature has a texture.
        :return: a boolean
        &#34;&#34;&#34;
        return self.texture is not None

    def get_geom(self, user_arguments=None, feature_list=None, material_indexes=dict()):
        &#34;&#34;&#34;
        Get the geometry of the feature.
        :return: a boolean
        &#34;&#34;&#34;
        if self.geom is not None and len(self.geom.triangles) &gt; 0 and len(self.get_geom_as_triangles()) &gt; 0:
            return [self]
        else:
            return []


class FeatureList(object):
    &#34;&#34;&#34;
    A decorated list of Feature instances.
    &#34;&#34;&#34;

    # The color config used to create colored materials
    color_config = None
    # The material used by default for geometries
    default_mat = None

    def __init__(self, features: list[Feature] = None):
        self.features = list()
        if FeatureList.default_mat is None:
            FeatureList.default_mat = self.get_color_config().get_default_color()
        self.materials = [FeatureList.default_mat]
        if(features):
            self.features.extend(features)

    def __iter__(self):
        return iter(self.features)

    def __getitem__(self, item):
        if isinstance(item, slice):
            features_class = self.__class__
            return features_class(self.features.__getitem__(item))
        # item is then an int type:
        return self.features.__getitem__(item)

    def __add__(self, other: &#39;FeatureList&#39;):
        features_class = self.__class__
        new_features = features_class(self.features)
        new_features.features.extend(other.features)
        return new_features

    def append(self, feature: Feature):
        self.features.append(feature)

    def extend(self, others: &#39;FeatureList&#39;):
        self.features.extend(others)

    def get_features(self):
        &#34;&#34;&#34;
        Return (recursively) all the features in this FeatureList.
        :return: a list of Feature instances
        &#34;&#34;&#34;
        if not self.is_list_of_feature_list():
            return self.features
        else:
            features = list()
            for objs in self.features:
                features.extend(objs.get_features())
            return features

    def set_features(self, features: list[Feature]):
        &#34;&#34;&#34;
        Set the list of features.
        :param features: a list of Feature
        &#34;&#34;&#34;
        self.features = features

    def delete_features_ref(self):
        &#34;&#34;&#34;Delete the reference to the features contained by this instance, so the features are destroyed when unused.&#34;&#34;&#34;
        del self.features

    def __len__(self):
        return len(self.features)

    def is_list_of_feature_list(self):
        &#34;&#34;&#34;Check if this instance of FeatureList contains others FeatureList&#34;&#34;&#34;
        return isinstance(self.features[0], FeatureList)

    def get_centroid(self):
        &#34;&#34;&#34;
        Return the centroid of the FeatureList.
        The centroid is the average of the centroids of all the features.
        :return: an array
        &#34;&#34;&#34;
        centroid = [0., 0., 0.]
        for feature in self:
            centroid += feature.get_centroid()
        return np.array([centroid[0] / len(self),
                         centroid[1] / len(self),
                         centroid[2] / len(self)])

    def set_materials(self, materials):
        &#34;&#34;&#34;
        Set the materials of this object to a new array of materials.
        :param materials: an array of GlTFMaterial
        &#34;&#34;&#34;
        self.materials = materials

    def add_materials(self, materials):
        &#34;&#34;&#34;
        Extend the materials of this object with another array of materials.
        :param materials: an array of GlTFMaterial
        &#34;&#34;&#34;
        self.materials.extend(materials)

    def add_material(self, material):
        &#34;&#34;&#34;
        Extend the materials of this object with a GltF material.
        :param material: a GlTFMaterial
        &#34;&#34;&#34;
        self.materials.append(material)

    def get_material(self, index):
        &#34;&#34;&#34;
        Get the material at the index.
        :param index: the index (int) of the material
        :return: a glTF material
        &#34;&#34;&#34;
        return self.materials[index]

    def is_material_registered(self, material):
        &#34;&#34;&#34;
        Check if a material is already set in materials array
        :param material: a GlTFMaterial
        :return: bool
        &#34;&#34;&#34;
        for mat in self.materials:
            if(mat.rgba == material.rgba).all():
                return True
        return False

    def get_material_index(self, material):
        &#34;&#34;&#34;
        Get the index of a given material.
        Add it to the materials array if it is not found
        :param material: a GlTFMaterial
        :return: an index as int
        &#34;&#34;&#34;
        i = 0
        for mat in self.materials:
            if(mat.rgba == material.rgba).all():
                return i
            i = i + 1
        self.add_material(material)
        return i

    def translate_features(self, offset):
        &#34;&#34;&#34;
        Translate the features by adding an offset
        :param offset: the Vec3 translation offset
        &#34;&#34;&#34;
        # Translate the position of each object by an offset
        for feature in self.get_features():
            new_geom = []
            for triangle in feature.get_geom_as_triangles():
                new_position = []
                for points in triangle:
                    new_position.append(np.array(points + offset))
                new_geom.append(new_position)
            feature.set_triangles(new_geom)
            feature.set_box()

    def change_crs(self, transformer):
        &#34;&#34;&#34;
        Project the features into another CRS
        :param transformer: the transformer used to change the crs
        &#34;&#34;&#34;
        for feature in self.get_features():
            new_geom = []
            for triangle in feature.get_geom_as_triangles():
                new_position = []
                for point in triangle:
                    new_point = transformer.transform(point[0], point[1], point[2])
                    new_position.append(np.array(new_point))
                new_geom.append(new_position)
            feature.set_triangles(new_geom)
            feature.set_box()

    def scale_features(self, scale_factor):
        &#34;&#34;&#34;
        Rescale the features.
        :param scale_factor: the factor to scale the features
        &#34;&#34;&#34;
        centroid = self.get_centroid()
        for feature in self.get_features():
            new_geom = []
            for triangle in feature.get_geom_as_triangles():
                scaled_triangle = [((vertex - centroid) * scale_factor) + centroid for vertex in triangle]
                new_geom.append(scaled_triangle)
            feature.set_triangles(new_geom)
            feature.set_box()

    def get_textures(self):
        &#34;&#34;&#34;
        Return a dictionary of all the textures where the keys are the IDs of the features.
        :return: a dictionary of textures
        &#34;&#34;&#34;
        texture_dict = dict()
        for feature in self.get_features():
            texture_dict[feature.get_id()] = feature.get_texture()
        return texture_dict

    def set_features_geom(self, user_arguments=None):
        &#34;&#34;&#34;
        Set the geometry of the features.
        Keep only the features with geometry.
        &#34;&#34;&#34;
        features_with_geom = list()
        material_indexes = dict()
        for feature in self.features:
            features_with_geom.extend(feature.get_geom(user_arguments, self, material_indexes))
        self.set_features(features_with_geom)

    @classmethod
    def set_color_config(cls, config_path):
        &#34;&#34;&#34;
        Set the ColorConfig from a JSON file.
        The ColorConfig is used to created colored materials.
        :param config_path: path to the JSON file
        &#34;&#34;&#34;
        FeatureList.color_config = ColorConfig(config_path)

    @classmethod
    def get_color_config(cls):
        &#34;&#34;&#34;
        Return the ColorConfig used to created colored materials.
        :return: a ColorConfig
        &#34;&#34;&#34;
        if FeatureList.color_config is None:
            FeatureList.color_config = ColorConfig()
        return FeatureList.color_config

    @staticmethod
    def create_batch_table_extension(extension_name, ids=None, features=None):
        &#34;&#34;&#34;Virtual method to create a batch table extension.&#34;&#34;&#34;
        pass

    @staticmethod
    def create_bounding_volume_extension(extension_name, ids=None, features=None):
        &#34;&#34;&#34;Virtual method to create a bounding volume box extension.&#34;&#34;&#34;
        pass</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="py3dtilers.Common.feature.Feature"><code class="flex name class">
<span>class <span class="ident">Feature</span></span>
<span>(</span><span>id=None)</span>
</code></dt>
<dd>
<div class="desc"><p>The base class of all object that need to be tiled, in order to be
used with the corresponding tiler.</p>
<p>:param id: given identifier</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class Feature(object):
    &#34;&#34;&#34;
    The base class of all object that need to be tiled, in order to be
    used with the corresponding tiler.
    &#34;&#34;&#34;

    def __init__(self, id=None):
        &#34;&#34;&#34;
        :param id: given identifier
        &#34;&#34;&#34;

        self.geom = TriangleSoup()

        # Optional application specific data to be added to the batch table for this object
        self.batchtable_data = None

        # A Bounding Volume Box object
        self.box = None

        # The centroid of the box
        self.centroid = np.array([0, 0, 0])

        self.texture = None

        self.material_index = 0

        self.set_id(id)

    def set_id(self, id):
        &#34;&#34;&#34;
        Set the id of this feature.
        :param id: an id
        &#34;&#34;&#34;
        self.id = id

    def get_id(self):
        &#34;&#34;&#34;
        Return the id of the feature.
        &#34;&#34;&#34;
        return self.id

    def set_batchtable_data(self, data):
        &#34;&#34;&#34;
        Set the batch table data associed to this feature.
        :param data: a dictionary
        &#34;&#34;&#34;
        self.batchtable_data = data

    def get_batchtable_data(self):
        &#34;&#34;&#34;
        Return the batch table data associed to this feature.
        :return: a dictionary
        &#34;&#34;&#34;
        return self.batchtable_data

    def get_centroid(self):
        &#34;&#34;&#34;
        Return the centroid of this feature.
        :return: a 3D point as np array
        &#34;&#34;&#34;
        return self.centroid

    def get_bounding_volume_box(self):
        &#34;&#34;&#34;
        Return the BoundingVolumeBox of this feature.
        :return: a BoundingVolumeBox
        &#34;&#34;&#34;
        return self.box

    def get_geom_as_triangles(self):
        &#34;&#34;&#34;
        Return the triangles of this feature.
        :return: a list of triangles
        &#34;&#34;&#34;
        return self.geom.triangles[0]

    def set_triangles(self, triangles):
        &#34;&#34;&#34;
        Set the triangles of this feature.
        :param triangles: a list of triangles.
        &#34;&#34;&#34;
        self.geom.triangles[0] = triangles

    def set_box(self):
        &#34;&#34;&#34;
        Set the BoundingVolumeBox of this feature from its triangles.
        Also set the centroid.
        &#34;&#34;&#34;
        bbox = self.geom.getBbox()
        self.box = BoundingVolumeBox()
        self.box.set_from_mins_maxs(np.append(bbox[0], bbox[1]))

        # Set centroid from Bbox center
        self.centroid = np.array(self.box.get_center())

    def get_texture(self):
        &#34;&#34;&#34;
        Return the texture image of this feature.
        :return: a Pillow image
        &#34;&#34;&#34;
        return self.texture

    def set_texture(self, texture):
        &#34;&#34;&#34;
        Set the texture image of this feature.
        :param texture: a Pillow image
        &#34;&#34;&#34;
        self.texture = texture

    def has_texture(self):
        &#34;&#34;&#34;
        Check if the feature has a texture.
        :return: a boolean
        &#34;&#34;&#34;
        return self.texture is not None

    def get_geom(self, user_arguments=None, feature_list=None, material_indexes=dict()):
        &#34;&#34;&#34;
        Get the geometry of the feature.
        :return: a boolean
        &#34;&#34;&#34;
        if self.geom is not None and len(self.geom.triangles) &gt; 0 and len(self.get_geom_as_triangles()) &gt; 0:
            return [self]
        else:
            return []</code></pre>
</details>
<h3>Subclasses</h3>
<ul class="hlist">
<li><a title="py3dtilers.CityTiler.citym_cityobject.CityMCityObject" href="../CityTiler/citym_cityobject.html#py3dtilers.CityTiler.citym_cityobject.CityMCityObject">CityMCityObject</a></li>
<li><a title="py3dtilers.Common.polygon_extrusion.ExtrudedPolygon" href="polygon_extrusion.html#py3dtilers.Common.polygon_extrusion.ExtrudedPolygon">ExtrudedPolygon</a></li>
<li><a title="py3dtilers.GeojsonTiler.geojson.Geojson" href="../GeojsonTiler/geojson.html#py3dtilers.GeojsonTiler.geojson.Geojson">Geojson</a></li>
<li><a title="py3dtilers.IfcTiler.ifcObjectGeom.IfcObjectGeom" href="../IfcTiler/ifcObjectGeom.html#py3dtilers.IfcTiler.ifcObjectGeom.IfcObjectGeom">IfcObjectGeom</a></li>
<li><a title="py3dtilers.ObjTiler.obj.Obj" href="../ObjTiler/obj.html#py3dtilers.ObjTiler.obj.Obj">Obj</a></li>
<li><a title="py3dtilers.TilesetReader.tile_to_feature.TileToFeature" href="../TilesetReader/tile_to_feature.html#py3dtilers.TilesetReader.tile_to_feature.TileToFeature">TileToFeature</a></li>
</ul>
<h3>Methods</h3>
<dl>
<dt id="py3dtilers.Common.feature.Feature.get_batchtable_data"><code class="name flex">
<span>def <span class="ident">get_batchtable_data</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Return the batch table data associed to this feature.
:return: a dictionary</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_batchtable_data(self):
    &#34;&#34;&#34;
    Return the batch table data associed to this feature.
    :return: a dictionary
    &#34;&#34;&#34;
    return self.batchtable_data</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.get_bounding_volume_box"><code class="name flex">
<span>def <span class="ident">get_bounding_volume_box</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Return the BoundingVolumeBox of this feature.
:return: a BoundingVolumeBox</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_bounding_volume_box(self):
    &#34;&#34;&#34;
    Return the BoundingVolumeBox of this feature.
    :return: a BoundingVolumeBox
    &#34;&#34;&#34;
    return self.box</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.get_centroid"><code class="name flex">
<span>def <span class="ident">get_centroid</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Return the centroid of this feature.
:return: a 3D point as np array</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_centroid(self):
    &#34;&#34;&#34;
    Return the centroid of this feature.
    :return: a 3D point as np array
    &#34;&#34;&#34;
    return self.centroid</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.get_geom"><code class="name flex">
<span>def <span class="ident">get_geom</span></span>(<span>self, user_arguments=None, feature_list=None, material_indexes={})</span>
</code></dt>
<dd>
<div class="desc"><p>Get the geometry of the feature.
:return: a boolean</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_geom(self, user_arguments=None, feature_list=None, material_indexes=dict()):
    &#34;&#34;&#34;
    Get the geometry of the feature.
    :return: a boolean
    &#34;&#34;&#34;
    if self.geom is not None and len(self.geom.triangles) &gt; 0 and len(self.get_geom_as_triangles()) &gt; 0:
        return [self]
    else:
        return []</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.get_geom_as_triangles"><code class="name flex">
<span>def <span class="ident">get_geom_as_triangles</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Return the triangles of this feature.
:return: a list of triangles</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_geom_as_triangles(self):
    &#34;&#34;&#34;
    Return the triangles of this feature.
    :return: a list of triangles
    &#34;&#34;&#34;
    return self.geom.triangles[0]</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.get_id"><code class="name flex">
<span>def <span class="ident">get_id</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Return the id of the feature.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_id(self):
    &#34;&#34;&#34;
    Return the id of the feature.
    &#34;&#34;&#34;
    return self.id</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.get_texture"><code class="name flex">
<span>def <span class="ident">get_texture</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Return the texture image of this feature.
:return: a Pillow image</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_texture(self):
    &#34;&#34;&#34;
    Return the texture image of this feature.
    :return: a Pillow image
    &#34;&#34;&#34;
    return self.texture</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.has_texture"><code class="name flex">
<span>def <span class="ident">has_texture</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Check if the feature has a texture.
:return: a boolean</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def has_texture(self):
    &#34;&#34;&#34;
    Check if the feature has a texture.
    :return: a boolean
    &#34;&#34;&#34;
    return self.texture is not None</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.set_batchtable_data"><code class="name flex">
<span>def <span class="ident">set_batchtable_data</span></span>(<span>self, data)</span>
</code></dt>
<dd>
<div class="desc"><p>Set the batch table data associed to this feature.
:param data: a dictionary</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def set_batchtable_data(self, data):
    &#34;&#34;&#34;
    Set the batch table data associed to this feature.
    :param data: a dictionary
    &#34;&#34;&#34;
    self.batchtable_data = data</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.set_box"><code class="name flex">
<span>def <span class="ident">set_box</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Set the BoundingVolumeBox of this feature from its triangles.
Also set the centroid.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def set_box(self):
    &#34;&#34;&#34;
    Set the BoundingVolumeBox of this feature from its triangles.
    Also set the centroid.
    &#34;&#34;&#34;
    bbox = self.geom.getBbox()
    self.box = BoundingVolumeBox()
    self.box.set_from_mins_maxs(np.append(bbox[0], bbox[1]))

    # Set centroid from Bbox center
    self.centroid = np.array(self.box.get_center())</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.set_id"><code class="name flex">
<span>def <span class="ident">set_id</span></span>(<span>self, id)</span>
</code></dt>
<dd>
<div class="desc"><p>Set the id of this feature.
:param id: an id</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def set_id(self, id):
    &#34;&#34;&#34;
    Set the id of this feature.
    :param id: an id
    &#34;&#34;&#34;
    self.id = id</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.set_texture"><code class="name flex">
<span>def <span class="ident">set_texture</span></span>(<span>self, texture)</span>
</code></dt>
<dd>
<div class="desc"><p>Set the texture image of this feature.
:param texture: a Pillow image</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def set_texture(self, texture):
    &#34;&#34;&#34;
    Set the texture image of this feature.
    :param texture: a Pillow image
    &#34;&#34;&#34;
    self.texture = texture</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.Feature.set_triangles"><code class="name flex">
<span>def <span class="ident">set_triangles</span></span>(<span>self, triangles)</span>
</code></dt>
<dd>
<div class="desc"><p>Set the triangles of this feature.
:param triangles: a list of triangles.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def set_triangles(self, triangles):
    &#34;&#34;&#34;
    Set the triangles of this feature.
    :param triangles: a list of triangles.
    &#34;&#34;&#34;
    self.geom.triangles[0] = triangles</code></pre>
</details>
</dd>
</dl>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList"><code class="flex name class">
<span>class <span class="ident">FeatureList</span></span>
<span>(</span><span>features: list[<a title="py3dtilers.Common.feature.Feature" href="#py3dtilers.Common.feature.Feature">Feature</a>] = None)</span>
</code></dt>
<dd>
<div class="desc"><p>A decorated list of Feature instances.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class FeatureList(object):
    &#34;&#34;&#34;
    A decorated list of Feature instances.
    &#34;&#34;&#34;

    # The color config used to create colored materials
    color_config = None
    # The material used by default for geometries
    default_mat = None

    def __init__(self, features: list[Feature] = None):
        self.features = list()
        if FeatureList.default_mat is None:
            FeatureList.default_mat = self.get_color_config().get_default_color()
        self.materials = [FeatureList.default_mat]
        if(features):
            self.features.extend(features)

    def __iter__(self):
        return iter(self.features)

    def __getitem__(self, item):
        if isinstance(item, slice):
            features_class = self.__class__
            return features_class(self.features.__getitem__(item))
        # item is then an int type:
        return self.features.__getitem__(item)

    def __add__(self, other: &#39;FeatureList&#39;):
        features_class = self.__class__
        new_features = features_class(self.features)
        new_features.features.extend(other.features)
        return new_features

    def append(self, feature: Feature):
        self.features.append(feature)

    def extend(self, others: &#39;FeatureList&#39;):
        self.features.extend(others)

    def get_features(self):
        &#34;&#34;&#34;
        Return (recursively) all the features in this FeatureList.
        :return: a list of Feature instances
        &#34;&#34;&#34;
        if not self.is_list_of_feature_list():
            return self.features
        else:
            features = list()
            for objs in self.features:
                features.extend(objs.get_features())
            return features

    def set_features(self, features: list[Feature]):
        &#34;&#34;&#34;
        Set the list of features.
        :param features: a list of Feature
        &#34;&#34;&#34;
        self.features = features

    def delete_features_ref(self):
        &#34;&#34;&#34;Delete the reference to the features contained by this instance, so the features are destroyed when unused.&#34;&#34;&#34;
        del self.features

    def __len__(self):
        return len(self.features)

    def is_list_of_feature_list(self):
        &#34;&#34;&#34;Check if this instance of FeatureList contains others FeatureList&#34;&#34;&#34;
        return isinstance(self.features[0], FeatureList)

    def get_centroid(self):
        &#34;&#34;&#34;
        Return the centroid of the FeatureList.
        The centroid is the average of the centroids of all the features.
        :return: an array
        &#34;&#34;&#34;
        centroid = [0., 0., 0.]
        for feature in self:
            centroid += feature.get_centroid()
        return np.array([centroid[0] / len(self),
                         centroid[1] / len(self),
                         centroid[2] / len(self)])

    def set_materials(self, materials):
        &#34;&#34;&#34;
        Set the materials of this object to a new array of materials.
        :param materials: an array of GlTFMaterial
        &#34;&#34;&#34;
        self.materials = materials

    def add_materials(self, materials):
        &#34;&#34;&#34;
        Extend the materials of this object with another array of materials.
        :param materials: an array of GlTFMaterial
        &#34;&#34;&#34;
        self.materials.extend(materials)

    def add_material(self, material):
        &#34;&#34;&#34;
        Extend the materials of this object with a GltF material.
        :param material: a GlTFMaterial
        &#34;&#34;&#34;
        self.materials.append(material)

    def get_material(self, index):
        &#34;&#34;&#34;
        Get the material at the index.
        :param index: the index (int) of the material
        :return: a glTF material
        &#34;&#34;&#34;
        return self.materials[index]

    def is_material_registered(self, material):
        &#34;&#34;&#34;
        Check if a material is already set in materials array
        :param material: a GlTFMaterial
        :return: bool
        &#34;&#34;&#34;
        for mat in self.materials:
            if(mat.rgba == material.rgba).all():
                return True
        return False

    def get_material_index(self, material):
        &#34;&#34;&#34;
        Get the index of a given material.
        Add it to the materials array if it is not found
        :param material: a GlTFMaterial
        :return: an index as int
        &#34;&#34;&#34;
        i = 0
        for mat in self.materials:
            if(mat.rgba == material.rgba).all():
                return i
            i = i + 1
        self.add_material(material)
        return i

    def translate_features(self, offset):
        &#34;&#34;&#34;
        Translate the features by adding an offset
        :param offset: the Vec3 translation offset
        &#34;&#34;&#34;
        # Translate the position of each object by an offset
        for feature in self.get_features():
            new_geom = []
            for triangle in feature.get_geom_as_triangles():
                new_position = []
                for points in triangle:
                    new_position.append(np.array(points + offset))
                new_geom.append(new_position)
            feature.set_triangles(new_geom)
            feature.set_box()

    def change_crs(self, transformer):
        &#34;&#34;&#34;
        Project the features into another CRS
        :param transformer: the transformer used to change the crs
        &#34;&#34;&#34;
        for feature in self.get_features():
            new_geom = []
            for triangle in feature.get_geom_as_triangles():
                new_position = []
                for point in triangle:
                    new_point = transformer.transform(point[0], point[1], point[2])
                    new_position.append(np.array(new_point))
                new_geom.append(new_position)
            feature.set_triangles(new_geom)
            feature.set_box()

    def scale_features(self, scale_factor):
        &#34;&#34;&#34;
        Rescale the features.
        :param scale_factor: the factor to scale the features
        &#34;&#34;&#34;
        centroid = self.get_centroid()
        for feature in self.get_features():
            new_geom = []
            for triangle in feature.get_geom_as_triangles():
                scaled_triangle = [((vertex - centroid) * scale_factor) + centroid for vertex in triangle]
                new_geom.append(scaled_triangle)
            feature.set_triangles(new_geom)
            feature.set_box()

    def get_textures(self):
        &#34;&#34;&#34;
        Return a dictionary of all the textures where the keys are the IDs of the features.
        :return: a dictionary of textures
        &#34;&#34;&#34;
        texture_dict = dict()
        for feature in self.get_features():
            texture_dict[feature.get_id()] = feature.get_texture()
        return texture_dict

    def set_features_geom(self, user_arguments=None):
        &#34;&#34;&#34;
        Set the geometry of the features.
        Keep only the features with geometry.
        &#34;&#34;&#34;
        features_with_geom = list()
        material_indexes = dict()
        for feature in self.features:
            features_with_geom.extend(feature.get_geom(user_arguments, self, material_indexes))
        self.set_features(features_with_geom)

    @classmethod
    def set_color_config(cls, config_path):
        &#34;&#34;&#34;
        Set the ColorConfig from a JSON file.
        The ColorConfig is used to created colored materials.
        :param config_path: path to the JSON file
        &#34;&#34;&#34;
        FeatureList.color_config = ColorConfig(config_path)

    @classmethod
    def get_color_config(cls):
        &#34;&#34;&#34;
        Return the ColorConfig used to created colored materials.
        :return: a ColorConfig
        &#34;&#34;&#34;
        if FeatureList.color_config is None:
            FeatureList.color_config = ColorConfig()
        return FeatureList.color_config

    @staticmethod
    def create_batch_table_extension(extension_name, ids=None, features=None):
        &#34;&#34;&#34;Virtual method to create a batch table extension.&#34;&#34;&#34;
        pass

    @staticmethod
    def create_bounding_volume_extension(extension_name, ids=None, features=None):
        &#34;&#34;&#34;Virtual method to create a bounding volume box extension.&#34;&#34;&#34;
        pass</code></pre>
</details>
<h3>Subclasses</h3>
<ul class="hlist">
<li><a title="py3dtilers.CityTiler.citym_cityobject.CityMCityObjects" href="../CityTiler/citym_cityobject.html#py3dtilers.CityTiler.citym_cityobject.CityMCityObjects">CityMCityObjects</a></li>
<li><a title="py3dtilers.Common.lod_feature_list.LodFeatureList" href="lod_feature_list.html#py3dtilers.Common.lod_feature_list.LodFeatureList">LodFeatureList</a></li>
<li><a title="py3dtilers.GeojsonTiler.geojson.Geojsons" href="../GeojsonTiler/geojson.html#py3dtilers.GeojsonTiler.geojson.Geojsons">Geojsons</a></li>
<li><a title="py3dtilers.IfcTiler.ifcObjectGeom.IfcObjectsGeom" href="../IfcTiler/ifcObjectGeom.html#py3dtilers.IfcTiler.ifcObjectGeom.IfcObjectsGeom">IfcObjectsGeom</a></li>
<li><a title="py3dtilers.ObjTiler.obj.Objs" href="../ObjTiler/obj.html#py3dtilers.ObjTiler.obj.Objs">Objs</a></li>
<li><a title="py3dtilers.TilesetReader.tile_to_feature.TileToFeatureList" href="../TilesetReader/tile_to_feature.html#py3dtilers.TilesetReader.tile_to_feature.TileToFeatureList">TileToFeatureList</a></li>
</ul>
<h3>Class variables</h3>
<dl>
<dt id="py3dtilers.Common.feature.FeatureList.color_config"><code class="name">var <span class="ident">color_config</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.default_mat"><code class="name">var <span class="ident">default_mat</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Static methods</h3>
<dl>
<dt id="py3dtilers.Common.feature.FeatureList.create_batch_table_extension"><code class="name flex">
<span>def <span class="ident">create_batch_table_extension</span></span>(<span>extension_name, ids=None, features=None)</span>
</code></dt>
<dd>
<div class="desc"><p>Virtual method to create a batch table extension.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@staticmethod
def create_batch_table_extension(extension_name, ids=None, features=None):
    &#34;&#34;&#34;Virtual method to create a batch table extension.&#34;&#34;&#34;
    pass</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.create_bounding_volume_extension"><code class="name flex">
<span>def <span class="ident">create_bounding_volume_extension</span></span>(<span>extension_name, ids=None, features=None)</span>
</code></dt>
<dd>
<div class="desc"><p>Virtual method to create a bounding volume box extension.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@staticmethod
def create_bounding_volume_extension(extension_name, ids=None, features=None):
    &#34;&#34;&#34;Virtual method to create a bounding volume box extension.&#34;&#34;&#34;
    pass</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.get_color_config"><code class="name flex">
<span>def <span class="ident">get_color_config</span></span>(<span>)</span>
</code></dt>
<dd>
<div class="desc"><p>Return the ColorConfig used to created colored materials.
:return: a ColorConfig</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@classmethod
def get_color_config(cls):
    &#34;&#34;&#34;
    Return the ColorConfig used to created colored materials.
    :return: a ColorConfig
    &#34;&#34;&#34;
    if FeatureList.color_config is None:
        FeatureList.color_config = ColorConfig()
    return FeatureList.color_config</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.set_color_config"><code class="name flex">
<span>def <span class="ident">set_color_config</span></span>(<span>config_path)</span>
</code></dt>
<dd>
<div class="desc"><p>Set the ColorConfig from a JSON file.
The ColorConfig is used to created colored materials.
:param config_path: path to the JSON file</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">@classmethod
def set_color_config(cls, config_path):
    &#34;&#34;&#34;
    Set the ColorConfig from a JSON file.
    The ColorConfig is used to created colored materials.
    :param config_path: path to the JSON file
    &#34;&#34;&#34;
    FeatureList.color_config = ColorConfig(config_path)</code></pre>
</details>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="py3dtilers.Common.feature.FeatureList.add_material"><code class="name flex">
<span>def <span class="ident">add_material</span></span>(<span>self, material)</span>
</code></dt>
<dd>
<div class="desc"><p>Extend the materials of this object with a GltF material.
:param material: a GlTFMaterial</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def add_material(self, material):
    &#34;&#34;&#34;
    Extend the materials of this object with a GltF material.
    :param material: a GlTFMaterial
    &#34;&#34;&#34;
    self.materials.append(material)</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.add_materials"><code class="name flex">
<span>def <span class="ident">add_materials</span></span>(<span>self, materials)</span>
</code></dt>
<dd>
<div class="desc"><p>Extend the materials of this object with another array of materials.
:param materials: an array of GlTFMaterial</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def add_materials(self, materials):
    &#34;&#34;&#34;
    Extend the materials of this object with another array of materials.
    :param materials: an array of GlTFMaterial
    &#34;&#34;&#34;
    self.materials.extend(materials)</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.append"><code class="name flex">
<span>def <span class="ident">append</span></span>(<span>self, feature: <a title="py3dtilers.Common.feature.Feature" href="#py3dtilers.Common.feature.Feature">Feature</a>)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def append(self, feature: Feature):
    self.features.append(feature)</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.change_crs"><code class="name flex">
<span>def <span class="ident">change_crs</span></span>(<span>self, transformer)</span>
</code></dt>
<dd>
<div class="desc"><p>Project the features into another CRS
:param transformer: the transformer used to change the crs</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def change_crs(self, transformer):
    &#34;&#34;&#34;
    Project the features into another CRS
    :param transformer: the transformer used to change the crs
    &#34;&#34;&#34;
    for feature in self.get_features():
        new_geom = []
        for triangle in feature.get_geom_as_triangles():
            new_position = []
            for point in triangle:
                new_point = transformer.transform(point[0], point[1], point[2])
                new_position.append(np.array(new_point))
            new_geom.append(new_position)
        feature.set_triangles(new_geom)
        feature.set_box()</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.delete_features_ref"><code class="name flex">
<span>def <span class="ident">delete_features_ref</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Delete the reference to the features contained by this instance, so the features are destroyed when unused.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def delete_features_ref(self):
    &#34;&#34;&#34;Delete the reference to the features contained by this instance, so the features are destroyed when unused.&#34;&#34;&#34;
    del self.features</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.extend"><code class="name flex">
<span>def <span class="ident">extend</span></span>(<span>self, others: <a title="py3dtilers.Common.feature.FeatureList" href="#py3dtilers.Common.feature.FeatureList">FeatureList</a>)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def extend(self, others: &#39;FeatureList&#39;):
    self.features.extend(others)</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.get_centroid"><code class="name flex">
<span>def <span class="ident">get_centroid</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Return the centroid of the FeatureList.
The centroid is the average of the centroids of all the features.
:return: an array</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_centroid(self):
    &#34;&#34;&#34;
    Return the centroid of the FeatureList.
    The centroid is the average of the centroids of all the features.
    :return: an array
    &#34;&#34;&#34;
    centroid = [0., 0., 0.]
    for feature in self:
        centroid += feature.get_centroid()
    return np.array([centroid[0] / len(self),
                     centroid[1] / len(self),
                     centroid[2] / len(self)])</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.get_features"><code class="name flex">
<span>def <span class="ident">get_features</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Return (recursively) all the features in this FeatureList.
:return: a list of Feature instances</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_features(self):
    &#34;&#34;&#34;
    Return (recursively) all the features in this FeatureList.
    :return: a list of Feature instances
    &#34;&#34;&#34;
    if not self.is_list_of_feature_list():
        return self.features
    else:
        features = list()
        for objs in self.features:
            features.extend(objs.get_features())
        return features</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.get_material"><code class="name flex">
<span>def <span class="ident">get_material</span></span>(<span>self, index)</span>
</code></dt>
<dd>
<div class="desc"><p>Get the material at the index.
:param index: the index (int) of the material
:return: a glTF material</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_material(self, index):
    &#34;&#34;&#34;
    Get the material at the index.
    :param index: the index (int) of the material
    :return: a glTF material
    &#34;&#34;&#34;
    return self.materials[index]</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.get_material_index"><code class="name flex">
<span>def <span class="ident">get_material_index</span></span>(<span>self, material)</span>
</code></dt>
<dd>
<div class="desc"><p>Get the index of a given material.
Add it to the materials array if it is not found
:param material: a GlTFMaterial
:return: an index as int</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_material_index(self, material):
    &#34;&#34;&#34;
    Get the index of a given material.
    Add it to the materials array if it is not found
    :param material: a GlTFMaterial
    :return: an index as int
    &#34;&#34;&#34;
    i = 0
    for mat in self.materials:
        if(mat.rgba == material.rgba).all():
            return i
        i = i + 1
    self.add_material(material)
    return i</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.get_textures"><code class="name flex">
<span>def <span class="ident">get_textures</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Return a dictionary of all the textures where the keys are the IDs of the features.
:return: a dictionary of textures</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_textures(self):
    &#34;&#34;&#34;
    Return a dictionary of all the textures where the keys are the IDs of the features.
    :return: a dictionary of textures
    &#34;&#34;&#34;
    texture_dict = dict()
    for feature in self.get_features():
        texture_dict[feature.get_id()] = feature.get_texture()
    return texture_dict</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.is_list_of_feature_list"><code class="name flex">
<span>def <span class="ident">is_list_of_feature_list</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"><p>Check if this instance of FeatureList contains others FeatureList</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_list_of_feature_list(self):
    &#34;&#34;&#34;Check if this instance of FeatureList contains others FeatureList&#34;&#34;&#34;
    return isinstance(self.features[0], FeatureList)</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.is_material_registered"><code class="name flex">
<span>def <span class="ident">is_material_registered</span></span>(<span>self, material)</span>
</code></dt>
<dd>
<div class="desc"><p>Check if a material is already set in materials array
:param material: a GlTFMaterial
:return: bool</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def is_material_registered(self, material):
    &#34;&#34;&#34;
    Check if a material is already set in materials array
    :param material: a GlTFMaterial
    :return: bool
    &#34;&#34;&#34;
    for mat in self.materials:
        if(mat.rgba == material.rgba).all():
            return True
    return False</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.scale_features"><code class="name flex">
<span>def <span class="ident">scale_features</span></span>(<span>self, scale_factor)</span>
</code></dt>
<dd>
<div class="desc"><p>Rescale the features.
:param scale_factor: the factor to scale the features</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def scale_features(self, scale_factor):
    &#34;&#34;&#34;
    Rescale the features.
    :param scale_factor: the factor to scale the features
    &#34;&#34;&#34;
    centroid = self.get_centroid()
    for feature in self.get_features():
        new_geom = []
        for triangle in feature.get_geom_as_triangles():
            scaled_triangle = [((vertex - centroid) * scale_factor) + centroid for vertex in triangle]
            new_geom.append(scaled_triangle)
        feature.set_triangles(new_geom)
        feature.set_box()</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.set_features"><code class="name flex">
<span>def <span class="ident">set_features</span></span>(<span>self, features: list[<a title="py3dtilers.Common.feature.Feature" href="#py3dtilers.Common.feature.Feature">Feature</a>])</span>
</code></dt>
<dd>
<div class="desc"><p>Set the list of features.
:param features: a list of Feature</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def set_features(self, features: list[Feature]):
    &#34;&#34;&#34;
    Set the list of features.
    :param features: a list of Feature
    &#34;&#34;&#34;
    self.features = features</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.set_features_geom"><code class="name flex">
<span>def <span class="ident">set_features_geom</span></span>(<span>self, user_arguments=None)</span>
</code></dt>
<dd>
<div class="desc"><p>Set the geometry of the features.
Keep only the features with geometry.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def set_features_geom(self, user_arguments=None):
    &#34;&#34;&#34;
    Set the geometry of the features.
    Keep only the features with geometry.
    &#34;&#34;&#34;
    features_with_geom = list()
    material_indexes = dict()
    for feature in self.features:
        features_with_geom.extend(feature.get_geom(user_arguments, self, material_indexes))
    self.set_features(features_with_geom)</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.set_materials"><code class="name flex">
<span>def <span class="ident">set_materials</span></span>(<span>self, materials)</span>
</code></dt>
<dd>
<div class="desc"><p>Set the materials of this object to a new array of materials.
:param materials: an array of GlTFMaterial</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def set_materials(self, materials):
    &#34;&#34;&#34;
    Set the materials of this object to a new array of materials.
    :param materials: an array of GlTFMaterial
    &#34;&#34;&#34;
    self.materials = materials</code></pre>
</details>
</dd>
<dt id="py3dtilers.Common.feature.FeatureList.translate_features"><code class="name flex">
<span>def <span class="ident">translate_features</span></span>(<span>self, offset)</span>
</code></dt>
<dd>
<div class="desc"><p>Translate the features by adding an offset
:param offset: the Vec3 translation offset</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def translate_features(self, offset):
    &#34;&#34;&#34;
    Translate the features by adding an offset
    :param offset: the Vec3 translation offset
    &#34;&#34;&#34;
    # Translate the position of each object by an offset
    for feature in self.get_features():
        new_geom = []
        for triangle in feature.get_geom_as_triangles():
            new_position = []
            for points in triangle:
                new_position.append(np.array(points + offset))
            new_geom.append(new_position)
        feature.set_triangles(new_geom)
        feature.set_box()</code></pre>
</details>
</dd>
</dl>
</dd>
</dl>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="py3dtilers.Common" href="index.html">py3dtilers.Common</a></code></li>
</ul>
</li>
<li><h3><a href="#header-classes">Classes</a></h3>
<ul>
<li>
<h4><code><a title="py3dtilers.Common.feature.Feature" href="#py3dtilers.Common.feature.Feature">Feature</a></code></h4>
<ul class="">
<li><code><a title="py3dtilers.Common.feature.Feature.get_batchtable_data" href="#py3dtilers.Common.feature.Feature.get_batchtable_data">get_batchtable_data</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.get_bounding_volume_box" href="#py3dtilers.Common.feature.Feature.get_bounding_volume_box">get_bounding_volume_box</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.get_centroid" href="#py3dtilers.Common.feature.Feature.get_centroid">get_centroid</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.get_geom" href="#py3dtilers.Common.feature.Feature.get_geom">get_geom</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.get_geom_as_triangles" href="#py3dtilers.Common.feature.Feature.get_geom_as_triangles">get_geom_as_triangles</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.get_id" href="#py3dtilers.Common.feature.Feature.get_id">get_id</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.get_texture" href="#py3dtilers.Common.feature.Feature.get_texture">get_texture</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.has_texture" href="#py3dtilers.Common.feature.Feature.has_texture">has_texture</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.set_batchtable_data" href="#py3dtilers.Common.feature.Feature.set_batchtable_data">set_batchtable_data</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.set_box" href="#py3dtilers.Common.feature.Feature.set_box">set_box</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.set_id" href="#py3dtilers.Common.feature.Feature.set_id">set_id</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.set_texture" href="#py3dtilers.Common.feature.Feature.set_texture">set_texture</a></code></li>
<li><code><a title="py3dtilers.Common.feature.Feature.set_triangles" href="#py3dtilers.Common.feature.Feature.set_triangles">set_triangles</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="py3dtilers.Common.feature.FeatureList" href="#py3dtilers.Common.feature.FeatureList">FeatureList</a></code></h4>
<ul class="">
<li><code><a title="py3dtilers.Common.feature.FeatureList.add_material" href="#py3dtilers.Common.feature.FeatureList.add_material">add_material</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.add_materials" href="#py3dtilers.Common.feature.FeatureList.add_materials">add_materials</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.append" href="#py3dtilers.Common.feature.FeatureList.append">append</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.change_crs" href="#py3dtilers.Common.feature.FeatureList.change_crs">change_crs</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.color_config" href="#py3dtilers.Common.feature.FeatureList.color_config">color_config</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.create_batch_table_extension" href="#py3dtilers.Common.feature.FeatureList.create_batch_table_extension">create_batch_table_extension</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.create_bounding_volume_extension" href="#py3dtilers.Common.feature.FeatureList.create_bounding_volume_extension">create_bounding_volume_extension</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.default_mat" href="#py3dtilers.Common.feature.FeatureList.default_mat">default_mat</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.delete_features_ref" href="#py3dtilers.Common.feature.FeatureList.delete_features_ref">delete_features_ref</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.extend" href="#py3dtilers.Common.feature.FeatureList.extend">extend</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.get_centroid" href="#py3dtilers.Common.feature.FeatureList.get_centroid">get_centroid</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.get_color_config" href="#py3dtilers.Common.feature.FeatureList.get_color_config">get_color_config</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.get_features" href="#py3dtilers.Common.feature.FeatureList.get_features">get_features</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.get_material" href="#py3dtilers.Common.feature.FeatureList.get_material">get_material</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.get_material_index" href="#py3dtilers.Common.feature.FeatureList.get_material_index">get_material_index</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.get_textures" href="#py3dtilers.Common.feature.FeatureList.get_textures">get_textures</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.is_list_of_feature_list" href="#py3dtilers.Common.feature.FeatureList.is_list_of_feature_list">is_list_of_feature_list</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.is_material_registered" href="#py3dtilers.Common.feature.FeatureList.is_material_registered">is_material_registered</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.scale_features" href="#py3dtilers.Common.feature.FeatureList.scale_features">scale_features</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.set_color_config" href="#py3dtilers.Common.feature.FeatureList.set_color_config">set_color_config</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.set_features" href="#py3dtilers.Common.feature.FeatureList.set_features">set_features</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.set_features_geom" href="#py3dtilers.Common.feature.FeatureList.set_features_geom">set_features_geom</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.set_materials" href="#py3dtilers.Common.feature.FeatureList.set_materials">set_materials</a></code></li>
<li><code><a title="py3dtilers.Common.feature.FeatureList.translate_features" href="#py3dtilers.Common.feature.FeatureList.translate_features">translate_features</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
</footer>
</body>
</html>